/**
 * 
 */
package ml.practicum.logistic;


/**
 * 
 * @author joscha
 *
 */
public final class BasicLV extends Number implements LogisticValue {

	/**
	 * 
	 */
	private static final long serialVersionUID = 2547581312926727406L;
	private double value;
	
	public BasicLV(double value) {
		setValue(value);
	}
	
	/* (non-Javadoc)
	 * @see mlprac.data.interfaces.LogisticValueInterface#getValue()
	 */
	public double getValue() {
		return value;
	}

	/* (non-Javadoc)
	 * @see mlprac.data.interfaces.LogisticValueInterface#setValue(double)
	 */
	public void setValue(double value) {
		if (value >= 0 && value <= 1){
			this.value = value;
		}else{
			throw new IllegalArgumentException("Logistic value(" + value + ")out of bounds, Input or output, missing in data?");
		}
	}

	/* (non-Javadoc)
	 * @see java.lang.Comparable#compareTo(java.lang.Object)
	 */
	public int compareTo(LogisticValue other){
		if (other == this) {
			return 0;
		}
		double difference = getValue() - other.getValue();
		if (difference == 0){
			return 0;
		}else if (difference < 0){
			return -1;
		}else{
			return 1;
		}
	}

	@Override
	public double doubleValue() {
		// TODO Auto-generated method stub
		return value;
	}

	@Override
	public float floatValue() {
		// TODO Auto-generated method stub
		return Double.valueOf(value).floatValue() ;
	}

	@Override
	public int intValue() {
		// TODO Auto-generated method stub
		return Double.valueOf(value).intValue();
	}

	@Override
	public long longValue() {
		// TODO Auto-generated method stub
		return Double.valueOf(value).longValue();
	}
	
	public String toString(){
		return ((Double)value).toString(); 
	}
}
